In [1]:
import numpy as np
from matplotlib import pyplot as plt
from __future__ import division
from itertools import product
from spacetime.CA_Simulators.CAs import *
from spacetime.Local_Measures.Transducers import *
%matplotlib inline
In [2]:
print rule_number_conversion(54, 2, 1)
In [3]:
start = np.zeros(20, dtype = int)
example = ECA(54, start)
print 'full lookup table'
example.lookup_table(True)
print 'lookup table value for neighborhood (0,0,1)'
print example.lookup_table()[(0,0,1)]
In [4]:
print rule_number_conversion(18, 2, 1)
In [5]:
start = np.zeros(20, dtype = int)
example = ECA(18, start)
print 'full lookup table'
example.lookup_table(True)
print 'lookup table value for neighborhood (0,0,1)'
print example.lookup_table()[(0,0,1)]
Test external lookup table (multi-dimensional np array) code for rule 18
In [6]:
A = 2
r = 1
table = lookup_table(18, 2, 1)
R = 2*r + 1
scan = tuple(np.arange(0,A)[::-1])
for a in product(scan, repeat = R):
print a, table[a]
In [7]:
x = [0,1,1,0]
print neighborhood(x, 1)
for item in neighborhood(x, 1):
print item
In [8]:
print max_rule(2,1)
In [9]:
print example.current_state()
example.evolve(1)
print example.current_state()
example.reset([0,]*5 + [1] + [0,]*5)
print example.current_state()
example.evolve(1)
print example.current_state()
In [10]:
print np.random.choice([0,1], 10 )
In [11]:
start = n_ones(20, 1)
test = ECA(18, start)
test.evolve(10)
print test.get_spacetime()
test.rewind(5)
print 'break'
print test.get_spacetime()
In [12]:
domain_state = domain_18(20)
print domain_state
t = transducer(*transducer_18())
print t.scan(domain_state)
In [13]:
dim = 400
start = random_state(dim, 2)
test = CA(18, 2, 1, start)
test.evolve(dim)
In [14]:
diagram(test.get_spacetime(), edgecolors='none')
External transduction of CA.get_spacetime()
In [15]:
t = transducer(*transducer_18())
transduced = t.spacetime_scan(test.get_spacetime(), direction ='left')
In [16]:
diagram(transduced, colors = plt.cm.bone, edgecolors = 'none')
In [17]:
masked = t.spacetime_mask(test.get_spacetime(), 2)
In [18]:
diagram(masked, colors = plt.cm.bone, edgecolors = 'none')
In [19]:
filtered = t.spacetime_filter(test.get_spacetime(), fill=True)
In [20]:
diagram(filtered, colors = plt.cm.Blues, edgecolors = 'none')
In [21]:
A = 3
R = 2
print max_rule(A, R)
In [24]:
start = random_state(500, A)
test = CA(68513215896546121325651496846315418, A, R, start)
test.evolve(500)
In [25]:
diagram(test.get_spacetime(), colors = plt.cm.spring, edgecolors = 'none')
In [ ]: